change_colnames <- function(df){
  cols <- c("ID_CODE", "STATE_CODE", "ORI","GROUP_NUMBER","DIVISION","YEAR","CITY_SEQUENCE","CORE_CITY",
            "COVERED_BY_CODE","LAST_UPDATE","FIELD_OFFICE","NUMBER_MONTHS_REPORTED","AGENCY_COUNT",
            "POP_1","COUNTY_1","MSA_1","POP_2","COUNTY_2","MSA_2","POP_3","COUNTY_3","MSA_3",
            "FOLLOW_UP","SPECIAL_MAILING_GROUP","SPECIAL_MAILING_ADDRESS","AGENCY_NAME","AGENCY_STATE_NAME",
            "MAILING_ADDRESS_1","MAILING_ADDRESS_2","MAILING_ADDRESS_3","MAILING_ADDRESS_4",
            "ZIP_CODE")
  start <- length(cols) + 1
  stop <- length(colnames(df))
  colnames(df) <- c(cols,colnames(df)[start:stop])
  return(df)
  
}


make_crime_variables <- function(df){
  temp1 <- df %>%
    select(V96,V214,V332,V450,V568,V686,V804,V922,V1040,V1158,V1276,V1394)%>%
    mutate(Murder = rowSums(.)) %>% select(Murder)
  temp2 <- df %>%
    select(V98,V216,V334,V452,V570,V688,V806,V924,V1042,V1160,V1278,V1396)%>%
    mutate(Rape = rowSums(.)) %>% select(Rape)
  temp3 <- df %>%
    select(V101,V219,V337,V455,V573,V691,V809,V927,V1045,V1163,V1281,V1399)%>%
    mutate(Robbery = rowSums(.)) %>% select(Robbery)
  temp4 <- df %>%
    select(V112,V230,V348,V466,V584,V702,V820,V938,V1056,V1174,V1292,V1410)%>%
    mutate(Burglary = rowSums(.)) %>% select(Burglary)
  temp5 <- df %>%
    select(V106,V224,V342,V460,V578,V696,V814,V932,V1050,V1168,V1286,V1404)%>%
    mutate(Assault = rowSums(.)) %>% select(Assault)
  df <- bind_cols(df,temp1,temp2,temp3,temp4,temp5)         
  return(df)
}
